<template>
  <view class="container"></view>
</template>

<style scoped lang="scss" rel="stylesheet/scss">

</style>

<script>
  export default {
    data() {
      return {
      }
    },

    components: {
    },

    computed: {
    },

    methods: {
    },
    onLoad(options) {
      console.log("options", options)
      let payParams = {}
      try {
        payParams = JSON.parse(decodeURIComponent(options.payParams))
        console.log("payParams", payParams);
      } catch (err) {
        wx.showModal({
          title: '提示',
          content: '支付参数解析失败！',
          showCancel: false,
          success(res) {}
        })

        return
      }
      if(payParams.timestamp){

      wx.requestPayment({
        timeStamp: payParams.timestamp,
        nonceStr: payParams.nonceStr,
        package: payParams.packageVal,
        signType: payParams.signType,
        paySign: payParams.paySign,
        success (res) {
          console.log('success', res);
          wx.redirectTo({
            url: `/pages/webview?goPayResult=1&wxID=${options.wxID}&orderId=${options.orderId}&type=${options.type}`
          })
        },
        fail (res) {
          console.log('fail handler::', res)
          wx.redirectTo({
            url: `/pages/webview?goPayResult=1&wxID=${options.wxID}&orderId=${options.orderId}&type=${options.type}`
          })
        }
      })
    }

    },
  }
</script>

